package service;


/**
 * @Author: xwg
 * @CreateDate: 2023/4/9
 */


public class SimpleMulti {
//    本示例运行多次 效果不同 表现了多线程代码运行的不确定性 步调不一致 表现在运行多次结果不同
    public static void main(String[] args) {
        Runnable first = () -> {
            Integer i = 10;
            while (true) {
                System.out.println("++++++++++++" + Thread.currentThread().getName());

                i--;
                if (i < 0) {
                    break;
                }
            }
        };
        Runnable second = () -> {
            Integer j = 10;
            while (true) {
                System.out.println("------------" + Thread.currentThread().getName());
                if (j< 0) {
                    break;
                }
                j--;
            }
        };
        new Thread(first, "First").start();
        new Thread(second, "Second").start();


    }
}
